﻿#region Using directives

using System;
using System.ComponentModel;

#endregion

namespace NetROS.Tiers.Entities
{	
	///<summary>
	/// An object representation of the 'tblObracunOsobaObustavaNaknada' table. [No description found the database]	
	///</summary>
	/// <remarks>
	/// This file is generated once and will never be overwritten.
	/// </remarks>	
	[Serializable]
	[CLSCompliant(true)]
	public partial class ObracunOsobaObustavaNaknada : ObracunOsobaObustavaNaknadaBase
	{		
		#region Constructors

		///<summary>
		/// Creates a new <see cref="ObracunOsobaObustavaNaknada"/> instance.
		///</summary>
		public ObracunOsobaObustavaNaknada():base()
		{
		    DatumIsplate = DateTime.Today;
		}
        protected override void AddValidationRules()
        {
            base.AddValidationRules();
            //Validation rules based on database schema.
            //ValidationRules.AddRule(Validation.CommonRules.GreaterThanOrEqualToValue<Decimal?>
            //    , new Validation.CommonRules.CompareValueRuleArgs<Decimal?>("Iznos", 0));
            ValidationRules.AddRule(ValidateIDTip, new NetROS.Tiers.Entities.Validation.ValidationRuleArgs("IDObustavaNaknadaTip", "Tip"));
        }

		
		#endregion
        [Description(""), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, true)]
        public virtual System.Decimal? IDObustavaNaknadeTipSourceFaktorObracunaPutaIznos
        {
            get
            {
                if (IDObustavaNaknadaTipSource != null)
                {
                    return (IDObustavaNaknadaTipSource.FaktorObracuna)*Iznos;
                }
                return null;
            }

        }
        private bool ValidateIDTip(object target, NetROS.Tiers.Entities.Validation.ValidationRuleArgs e)
        {
            if (IDObustavaNaknadaTip == 0)
            {
                e.Description = "Izaberite tip";
                return false;
            }
            return true;
        }

        [Description(""), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, true)]
        public virtual System.Decimal? Dodatak
        {
            get
            {
                if (IDObustavaNaknadaTipSource != null && IDObustavaNaknadaTipSource.FaktorObracuna > 0)
                {
                    return Iznos;
                }
                return null;
            }

        }

        [Description(""), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, true)]
        public virtual System.Decimal? Odbitak
        {
            get
            {
                if (IDObustavaNaknadaTipSource != null && IDObustavaNaknadaTipSource.FaktorObracuna < 0)
                {
                    return Iznos;
                }
                return null;
            }

        }

	}
}
